import request from '@/utils/request'
import url from './url'

// 工单统计
export function statWo(params = {}) {
  return request({
    url: url.woStat,
    params
  })
}

// 编辑工单
export function editWo(data = {}) {
  const { id, workOrderId } = data
  return request({
    url: id || workOrderId ? url.woUpdate : url.woAdd,
    method: 'post',
    data
  })
}

// 工单 删除
export function delWo(workOrderId) {
  return request({
    url: url.woDel,
    // method: 'post',
    data: { workOrderId }
  })
}

// 查询工单详情
export function getWoInfo(workOrderId) {
  return request({
    url: url.woInfo,
    data: { workOrderId }
  })
}

// 企业服务记录
export function getServiceRecords(workOrderId) {
  return request({
    url: url.serviceRecords,
    data: { workOrderId }
  })
}

// 工单企业信息查询
export function getTenantByOrder(workOrderId) {
  return request({
    url: url.getTenantByOrder,
    data: { workOrderId }
  })
}

// 聊天
// - 聊天记录
export function getChatLogs(data) {
  return request({
    url: url.chatLogs,
    loading: false,
    showMsg: false,
    data
  })
}

// - 发送聊天消息
export function sendChat(data) {
  return request({
    url: url.sendChat,
    method: 'post',
    showMsg: false,
    loading: false,
    data
  })
}

// - 工单 操作记录
export function getWoOperateList(workOrderId) {
  return request({
    url: url.woOperatePage,
    data: {
      current: 1,
      size: 50,
      workOrderId
    },
    showMsg: false
  })
}

// 关闭工单
export function woClose(data) {
  return request({
    url: url.woClose,
    method: 'post',
    data
  })
}

// 工单 接单
export function woTake(workOrderId) {
  return request({
    url: url.woTake,
    data: { workOrderId }
  })
}

// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 
